﻿Imports System.Data.OleDb
Public Class message
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim name As String
        name = Convert.ToString(Context.Request.QueryString("DieterName"))
        Label1.Text = name
    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim name As String
        name = Convert.ToString(Context.Request.QueryString("DieterName"))
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        oleDbConn.Open()
        Dim MsgString As String = "Insert into UserMessages(Title,Member,Message,PostTime,Recipient) Values (@f1,@f2,@f3,@f4,@f5)"
        Dim Msgcmd As OleDbCommand = New OleDbCommand(MsgString, oleDbConn)
        Dim dateString As String
        dateString = Date.Now.ToString("dd/MM/yyyy")
        Msgcmd.CommandType = CommandType.Text
        Msgcmd.Parameters.AddWithValue("@f1", TextBox2.Text)
        Msgcmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        Msgcmd.Parameters.AddWithValue("@f3", TextBox1.Text)
        Msgcmd.Parameters.AddWithValue("@f4", dateString)
        Msgcmd.Parameters.AddWithValue("@f5", name)
       
        Msgcmd.ExecuteNonQuery()
        Response.Redirect("msgConfirm.aspx")

    End Sub
End Class